﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace WindowsFormsApplication1.LiftUIForms
{
    public partial class LiftUI : Form
    {
        Elevator elevator;

        public LiftUI(Elevator e)
        {
            InitializeComponent();
            elevator = e;
        }

        public void run()
        {
        }

        public void start()
        {
            Thread thread = new Thread(new ThreadStart(updateSelf));
            thread.Start(); 
        }

        public void updateSelf()
        {
            currentFloorLbl.Text = "" + elevator.getCurrentFloor();
            currentStatusLbl.Text = elevator.getMovingDirection();
            currentDoorsLbl.Text = elevator.getDoorStatus();
            Application.DoEvents();
            if (elevator.getDoorStatus().Equals("open"))
            {
                elevatorPicture.Image = Properties.Resources.inside_opened;
                Application.DoEvents();
            }
            else if (elevator.getDoorStatus().Equals("closed"))
            {
                elevatorPicture.Image = Properties.Resources.inside_close;
                Application.DoEvents();
            }
        }

        private void doNothing()
        {
        }

        private void LiftUI_Load(object sender, EventArgs e)
        {
        }

        private void updateTimer_Tick(object sender, EventArgs e)
        {
            updateSelf();
        }
    }
}
